<?php


class Form_Enroll extends Zend_Form {

   public function __construct($options = null) {
      parent::__construct($options);
      
      $modelCongregation = new Model_Congregation();
      $congregation = $modelCongregation->findOneBy('userid', $options['userid']);
      
      $this->setName('enroll');
      $fields = array(
         'congregation' => new Zend_Form_Element_Text('congregation', array('label' => 'Congregation', 'required' => true,
            'value' => $congregation->congregation)),
         'pastor' => new Zend_Form_Element_Text('pastor', array('label' => 'Pastor', 'required' => true,
            'value' => $congregation->pastor)),
         'phone' => new Zend_Form_Element_Text('phone', array('label' => 'Phone', 'required' => true,
            'value' => $congregation->phone)),
         'email' => new Zend_Form_Element_Text('email', array('label' => 'Email', 'required' => true,
            'value' => $congregation->email)),
         'website' => new Zend_Form_Element_Text('website', array('label' => 'Website', 'required' => true,
            'value' => $congregation->website)),
         'userid' => new Zend_Form_Element_Hidden('userid'),
         'submit' => new Zend_Form_Element_Submit('login', array('label' => 'enroll'))
      );
      
      $fields['email']->addValidator(new Zend_Validate_EmailAddress(true, true))
                          ->addFilter(new Zend_Filter_StringTrim())
                          ->isRequired();
      //$fields['userid']->addValidator(new App_Validate_Unique('congregation', 'userid'));
      
      $this->addElements($fields);
      $this->setMethod('post');
      $this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl(). '/pages/enroll/course/'.$options['course']);

   }



}